package com.interview.ujiuye1;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;

abstract class Person1{
    public Person1(){
        System.out.println("创建父类对象");
    }

    public abstract  void run();
}
class Teacher extends Person1{
    private String name;

    public Teacher(){
        super();
        System.out.println("创建Teacher对象");
    }
    @Override
    public void run() {
        System.out.println("run");
    }
}

public class Demo6 {
    public static void main(String[] args) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        //Computer描述电脑，Student描述学生信息，class也是一个对象用什么类描述：Class
        //xml文件不用了；Teacher.class
        Class<Teacher> teacherClass = Teacher.class;//applicationContext.xml Class.forName("包名+类名")去创建对象
        Field nameField = teacherClass.getDeclaredField("name");
        System.out.println("获取属性:"+nameField.getName());
        Constructor<Teacher> constructor = teacherClass.getConstructor();
        Teacher newInstance = constructor.newInstance();


        Teacher teacher = new Teacher();

        teacher.run();
        List<String> list = Arrays.asList("aaa","bbb","ccc");
        list.stream().map(str -> str.toUpperCase()).forEach(System.out::println);
    }
}
